Repository navigation
Conversation
A native stack overflow can disappear once its caller has unwound, while its query/input dependencies remain unchanged. Keeping that exception as a clean memoized value prevents a later shallow call from recovering. Leave only the observed V8 RangeError dirty before notifying parents, so parents that caught the failure also reevaluate their fallback results. Preserve normal result caching, ordinary exception identity and caching, and subscription cleanup. Guard classification of arbitrary thrown values. Add regression tests for native overflow retry, transitive parent fallback, ordinary throw values with throwing getters, and subscription cleanup. The new tests fail on the original implementation. After the change, both ESM and CJS suites pass 50 tests with one existing pending case. The packed npm artifact also fixes the Apollo reproduction across 3.13.4 and 4.3.8, Node 22.23.5 and 26.11.1, and both NODE_ENV modes. Refs apollographql/apollo-client#13534.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Refs apollographql/apollo-client#13534. Runnable Apollo reproduction: https://gist.github.com/duke-101/aacfc61fed4faeaf065822b18f915f40.
A native stack overflow can occur because the current caller has almost exhausted its stack.
Once that caller unwinds, the same computation can succeed without any input/dependency changes.
Caching the failure as clean instead keeps replaying the original RangeError.
Change
The classification is intentionally limited to a same-realm RangeError with the exact V8 message
"Maximum call stack size exceeded". Other RangeErrors, other engines' messages, promise results,
and ordinary exceptions keep their current behavior. This does not automatically retry a computation
or repair an infinite recursion.
Verification
The reproduction recovers in all eight combinations:
Apollo 3.13.4 / 4.3.8 × Node 22.23.5 / 26.11.1 × development / production.
The corresponding unmodified npm-package runs reproduce the retained identical RangeError in all eight.
public types, or build configuration change.
The upstream Mocha runner on Node 26.11.1 fails before test collection in the existing yargs loader
("require is not defined in ES module scope"), so I am not claiming the full unit suite passed
there. The packed-library Apollo reproductions were executed successfully on Node 26 independently
of that runner.
Review scope
Opening as a draft for feedback on treating this V8 resource failure differently from ordinary
memoized exceptions (original exception-caching design).
Consumers will still need a published optimism release and a dependency update after any merge;
the Apollo issue should remain open until the consumer path is addressed.
Prepared with AI assistance. The reproductions, red/green unit suites, and packed-package checks
above were actually executed. Production-mode reduced-stack checks are not evidence of incidence
in a deployed production environment.